<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./_react/react.development.js"></script>
  <script src="./_react/react-dom.development.js"></script>
  <script src="./_react/babel.js"></script>
</head>
<body>
<div id="app"></div>

<script type="text/babel">
  function App(){
    const [isShow, setIsShow] = React.useState(false)
    React.useEffect(()=>{
      document.addEventListener('click', handleClick)
      return ()=>{
        document.removeEventListener('click', handleClick)
      }
    },[])

    const handleClick = ()=>{
      console.log('哈哈哈哈正在显示吗', isShow)
      isShow && setIsShow(false)
    }
    return <div>
      <h1 onClick={(e)=>{e.stopPropagation();setIsShow(!isShow)}}>点我可以控制“哈哈哈哈”的显隐 （点其他空白的地方会让“哈哈哈哈”消失）</h1>
      {isShow && <div>哈哈哈哈</div>}
    </div>
  }
  ReactDOM.render(<App></App>,document.getElementById("app"))
</script>
</body>
</html>
